package com.gxa.hualian.utils;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
@Component
public class JsonResult {
    private String code;
    private String msg;
    private  Object data;
    private Map<String,Object > dataMap = new HashMap<>();

    public JsonResult() {
    }

    public JsonResult(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;

    }

    public String getCode() {
        return dataMap.get("code").toString();
    }

    public void setCode(String code) {

        dataMap.put("code",code);
    }

    public String getMsg() {

        return dataMap.get("msg").toString();
    }

    public void setMsg(String msg) {

        dataMap.put("msg",msg);
    }

    public Object getData() {
        return dataMap.get("data");
    }

    public void setData(Object data) {
        dataMap.put("data",data);
    }

    public void put(String key, Object value){
        dataMap.put(key,value);
    }

    public Map<String,Object> getDataMap(){
        return dataMap;
    }

    @Override
    public String toString() {
        return "JsonResult{" +
                "code='" + code + '\'' +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
